package tfd.scala.squib.demo.scenario;

import java.awt.{Dimension, Color}
import javax.swing.{JFrame}

import com.sun.scenario.scenegraph._
import com.sun.scenario.animation._

import tfd.scala.squib._
import tfd.scala.squib.event._
import tfd.scala.squib.scenario.scenegraph._
import tfd.scala.squib.scenario.scenegraph.Implicits._

object TimelineTest extends Application {
    
    val timeline = new Timeline()
    
    val frm = frame(
            'title->"SQUIB Scenegraph Demo",
            'visible -> true,
            'defaultCloseOperation -> JFrame.EXIT_ON_CLOSE,
            'size -> new Dimension(140,200),
            contents(
                   scenepanel("scene",
                        'scene -> group("root",
                                      translate("button", 10, 110,
                                          button('text->"Cycle Colors",
                                                  actionPerformed {
                                                  	System.out.println("Press")
                                                    if (!timeline.isRunning()) {
                                                        timeline.start()
                                                    }
                                                  }
                                          )
                                       )
                       ),  			
                       'background -> Color.GREEN
                   ) -> "Center"
             )
    )
    
    val clip = Clip.create(7000, scenepanel.id("scene"), "background",
             Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.RED, Color.YELLOW, Color.GREEN)
    timeline.schedule(clip)    

}
